package com.vlin.config.email;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.MailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

@Configuration
public class EmailConfig {
	
	@Autowired
	private EmailProperties emailProperties;
	

	@Bean
	public MailSender mailSender() {
		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
		mailSender.setHost(emailProperties.getHost());// 指定用来发送Email的邮件服务器主机名
		mailSender.setPort(emailProperties.getPort());// 默认端口，标准的SMTP端口
		mailSender.setUsername(emailProperties.getUsername());// 用户名
		mailSender.setPassword(emailProperties.getPassword());// 密码
		mailSender.setProtocol(emailProperties.getProtocol());
		return mailSender;
	}

}
